package com.zjl.spring.thread;

import java.util.concurrent.TimeUnit;

/**
 * @Auther: zhuangjl
 * @Date: 2021/11/08 17:07
 */
public class ThreadCycle {

    public static void main(String[] args) {

        //演示BLOCKED状态进入RUNNNABLE状态
        blockedToRunnable();
    }

    /**
     * 演示BLOCKED状态进入RUNNNABLE状态
     */
    public static void blockedToRunnable() {

        Thread t1 = new Thread(() -> {

            try {
                for (int i =0;i<10;i++){
                    System.out.println(Thread.currentThread().getName()+"开始执行任务,状态为："+Thread.currentThread().getState());
                }
                Thread.sleep(100000);
            } catch (InterruptedException e) {
                e.printStackTrace();
                System.out.println(Thread.currentThread().getName()+"中断异常,状态为："+Thread.currentThread().getState());
            }finally{
                System.out.println(Thread.currentThread().getName()+"执行任务结束,状态为："+Thread.currentThread().getState());
            }


        });
        t1.start();
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        t1.interrupt();

    }

    /**
     * 演示RUNNNING状态进入RUNNNABLE状态
     */
    public static void RunningToRunnable() {

    }

    /**
     * 演示RUNNABLE
     */
    public static void RunnableToIntercept() {

    }
}




